﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using OthelloGame;

namespace OthelloCognition
{
    /*
     * HOWTO
     * 
     * The state search in instantiated by invoking the examineBoard() method.
     * 
     * By contract with programmer, this method keeps a snapshot of the best move isolated 
     * so far, which is accessible through the read-only nextMove property.
     * 
     */
    public abstract class AbstractSolver
    {

        protected OthelloBoardLocation move;

        protected int count;

        protected PieceColors currentPlayer;

        public OthelloBoardLocation nextMove
        {
            get { return move; }
        }

        public virtual int expanded
        {
            get { return count; }
        }

        public abstract SolverEnum SolverName();

        public void searchGameState(OthelloGameBoard board)
        {
            count = 0;
            currentPlayer = board.PlayersTurn;
            examineBoard(board);
        }

        protected abstract void examineBoard(OthelloGameBoard board);

        public OthelloGameBoard expandState(OthelloGameBoard board, OthelloBoardLocation pit)
        {
            OthelloGameBoard newBoard = new OthelloGameBoard(board);
            newBoard.PlacePit(pit);
            count++;
            return newBoard;
        }

        virtual public void recordResult(bool isWinner)
        {
            // Default ignore result
        }
    }
}
